package project.suntray.com.core.app;

import android.content.Context;

import java.util.WeakHashMap;

/**
 * Created by zhangyang on 2017/12/12 13:46.
 * version 1
 * 创建一个类，J进行统一获取相关工具类
 * Final 类
 */
public final class Natte {

    /**
     * 将context 放入到集合中
     * @param context
     */
    public static final Configurtor init(Context context) {
        Configurtor.getInstance().getConfigurations().put(//
                      ConfigureType.APPLICATION_CONTEXT.name(),context.getApplicationContext());
        return  Configurtor.getInstance();
    }

    /**
     * 进行获取配置项的集合
     * @return
     */
    public static final WeakHashMap<String, Object> getConfigurators(){
        return Configurtor.getInstance().getConfigurations();
    }

    /**
     * 获取对应的 context 实例
     * @return
     */
    public static final Context getApplication() {
        return  (Context) Configurtor.getInstance().//
                            getConfigurations().get(ConfigureType.//
                                                APPLICATION_CONTEXT.name());
    }

    /**
     * 通过对应的键 获取对应的值!
     * @param key
     * @return
     */
    public static final<T> T getConfiguration(String key) {
        return  (T)Configurtor.getInstance().getConfigurations().get(key);
    }
}
